<script>
	export default {
		globalData: {
		    key:"",
			openid:'',
		    userInfo: null,
			hasUserInfo: false,
		    pubSiteUrl: "http://127.0.0.1/",
		    photoHttpsUrlHead: "https://7875-xueyou-1304421817.tcb.qcloud.la/",
			videoUrlHead:"cloud://xueyou.7875-xueyou-1304421817/",
			ownedCourses:[],
			
			subjectList: [{
			    name: "请选择学科",
			    id: 0,
			    icon: '0.png'
			  },
			  {
			    name: "语文",
			    id: 1,
			    icon: '1.png'
			  },
			  {
			    name: "数学",
			    id: 2,
			    icon: '2.png'
			  },
			  {
			    name: "英语",
			    id: 3,
			    icon: '3.png'
			  },
			  {
			    name: "思政",
			    id: 4,
			    icon: '4.png'
			  },
			  {
			    name: "历史",
			    id: 5,
			    icon: '5.png'
			  },
			  {
			    name: "地理",
			    id: 6,
			    icon: '6.png'
			  },
			  {
			    name: "生物",
			    id: 7,
			    icon: '9.png'
			  },
			  {
			    name: "物理",
			    id: 8,
			    icon: '7.png'
			  },
			  {
			    name: "化学",
			    id: 9,
			    icon: '8.png'
			  },
			  {
			    name: "信息",
			    id: 10,
			    icon: '10.png'
			  },
			  {
			    name: "科学",
			    id: 11,
			    icon: '11.png'
			  }
			],
			

	    },
		
		onLaunch: function() {
			console.log('App Launch')
		
			// 展示本地存储能力
			var logs = wx.getStorageSync('logs') || []
			logs.unshift(Date.now())
			wx.setStorageSync('logs', logs)
		
			// 登录
			wx.login({
			  success: res => {
				console.log('wx.login',res)
				// 发送 res.code 到后台换取 openId, sessionKey, unionId
			  }
			})
			// 获取用户信息
			wx.getSetting({
			  success: res => {
				console.log('wx.getSetting',res)

			  }
			})
			if (!wx.cloud) {
			  console.error('请使用 2.2.3 或以上的基础库以使用云能力')
			} else {
			  wx.cloud.init({
				// env 参数说明：
				//   env 参数决定接下来小程序发起的云开发调用（wx.cloud.xxx）会默认请求到哪个云环境的资源
				//   此处请填入环境 ID, 环境 ID 可打开云控制台查看
				//   如不填则使用默认环境（第一个创建的环境）
				env: 'xueyou',
				traceUser: true,
			  })
			}
			wx.cloud.callFunction({
				name: 'get_openid',
				complete: res => {
					console.log('云函数获取到的openid: ', res.result.openid)    
					this.globalData.openid = res.result.openid;
				}
			})
		},
		onShow: function() {
			console.log('App Show')
		},
		onHide: function() {
			console.log('App Hide')
		}
	}
</script>

<style>
	/*每个页面公共css */
</style>
